﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TimeSolve
{
    public class UnitManager
    {
        public enum UnitEnum_temperature { k, du }
        private UnitEnum_temperature _unitType_Temperature = UnitEnum_temperature.k;
        public UnitEnum_temperature unitType_Temperature
        {
            get { return _unitType_Temperature; }
            set
            {
                _unitType_Temperature = value;                
            }
        }

        public string UnitString_Temperature
        {
            get
            {
                switch (_unitType_Temperature)
                {
                    case UnitEnum_temperature.du:
                        return "℃";
                    default:
                        return "K";
                }
            }
            set { }
        }
        public double getTemperature(double ValueInK)
        {
            switch (_unitType_Temperature)
            {
                case UnitEnum_temperature.du:
                    return ValueInK - 273.15;
                default:
                    return ValueInK;
            }
        }
        public double setTemperature(double ValueToK)
        {
            switch (_unitType_Temperature)
            {
                case UnitEnum_temperature.du:
                    return ValueToK + 273.15;
                default:
                    return ValueToK;
            }
        }
        //private List<IDataUpdate> updatedFlag;
        //private void updateUnit(IDataUpdate parentPage)
        //{
        //    foreach (IDataUpdate updated in updatedFlag)//检查是否已更新过，避免重复
        //    {
        //        if (ReferenceEquals(parentPage, updated))
        //        {
        //            return;
        //        }
        //    }
        //    List<IDataUpdate> childrens = parentPage.updateAndGetChildren();
        //    updatedFlag.Add(parentPage);
        //    if (childrens != null)
        //    {
        //        foreach (IDataUpdate children in childrens)
        //        {
        //            if (children != null)
        //            {
        //                updateUnit(children);
        //            }
        //        }
        //    }
        //}
    }

}
